﻿using System;

namespace Domain
{
    public class HeapItem : IEquatable<HeapItem>
    {
        public IHeapItemValue value { get; private set; }
        public int key { get; private set; }

        public HeapItem(int key, IHeapItemValue value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value", "can not be initialized by null");
            }
            this.key = key;
            this.value = value;
        }

        public bool Equals(HeapItem other)
        {
            if (ReferenceEquals(null, other))
            {
                return false;
            }
            if (ReferenceEquals(this, other))
            {
                return true;
            }
            return value.Equals(other.value) && key == other.key;
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj))
            {
                return false;
            }
            return (GetType() == obj.GetType()) && Equals(obj as HeapItem);
        }
    }
}
